const http=require('http');
const querystring=require('querystring');
//客户端请求
var contents=querystring.stringify({
  name:'Tom',
  age:18,
  city:'beijing'
});

//声明请求参数
var options={
  host:'localhost',
  path:'/',
  port:8888,
  method:'POST',
  headers:{
    'Content-Type':'application/x-www-form-urlencoded',
    'Content-Length':contents.length
  }
};
//发送请求
var req=http.request(options,function(res){
  res.setEncoding('utf-8');
  res.on('data',function(data){
    console.log('后台返回数据');
    console.log('name参数的值为：' + data);
  })
});
req.write(contents);
//必须调用end()
req.end();
